pub mod away;
pub mod cbase;
pub mod goods;
pub mod ground;
pub mod out;
pub mod pair;
pub mod part;
pub mod pick;
pub mod queue;
pub mod sale;
pub mod stock;
pub mod work;

use super::{
    cur_time, err, err_value, json, ok, throw_err, Base, Client, ECode, Lock, MapSv, RNull, Resp,
    VBase, VMap, VRece, VSend, Value, VecV, SS,
};
use base::tbase::{box_psn, load_ring, try_rm_task, TBase};
use cbase::CBase;
use std::collections::HashMap;

pub use queue::{queue_job, time_job};

pub type MSV = HashMap<String, Vec<Value>>;

pub async fn doit(
    para: &Value,
    cmd: &str,
    key: &str,
    client: &Client,
    lock: Lock,
    tx: VSend,
) -> Resp {
    match cmd {
        "out" => {
            let v = out::Out;
            v.do_cmd(para, key, client).await
        }
        "goods" => {
            let v = goods::Goods;
            v.do_cmd(para, key, client, lock).await
        }
        "pair" => {
            let v = pair::Pair;
            v.do_cmd(para, key, client, lock).await
        }
        "away" => {
            let v = away::Away;
            v.do_cmd(para, key, client, lock).await
        }
        "pick" => {
            let v = pick::Pick;
            v.do_cmd(para, key, client, lock, tx).await
        }
        "sale" => {
            let v = sale::Sale;
            v.do_cmd(para, key, client).await
        }
        "part" => {
            let v = part::Part;
            v.do_cmd(para, key, client, lock).await
        }
        "stock" => {
            let v = stock::Stock;
            v.do_cmd(para, key, client, lock).await
        }
        "work" => {
            let v = work::Work;
            v.do_cmd(para, key, client).await
        }
        _ => throw_err!(ECode::NoServe, "no cmd"),
    }
}
